package com.tao.YanMoDesignPattern.template.notPattern;

/**
 * @Author Mi_Tao
 * @Date 2023/7/22
 * @Description 普通用户登陆控制的逻辑处理
 * @Version 1.0
 **/
public class WorkerLogin {

    public boolean login(WorkerModel lm){
        // 1、先从数据库获取登陆人员的信息
        WorkerModel wm = findWorkerByWorkerId(lm.getWorkId());

        // 2、判断从前台传递过来的登陆数据和数据库中已有的数据是否匹配
        // 判断用户是否存在，如果是null，说明用户肯定不存在
        if (wm != null){
            if (wm.getWorkId().equals(lm.getWorkId())&&wm.getPwd().equals(enctyptPwd(lm.getPwd()))){
                return true;
            }
            return false;
        }
        return false;
    }

    private WorkerModel findWorkerByWorkerId(String workId) {
        WorkerModel workerModel = new WorkerModel();
        workerModel.setWorkId("work001");
        workerModel.setPwd("pwdWork1");
        workerModel.setName("workName");
        workerModel.setUuid("123124124");
        return workerModel;
    }

    private String enctyptPwd(String pwd){
        // 加密，省略
        return pwd;
    }



}
